#-*- coding: utf-8 -*-
#@File    : LoginTest.PY
#@Time    : 2020/11/30  16:58
#@Software: PyCharm

from lib.config import HOST
import hashlib
def get_md5(pwd):
    md5 = hashlib.md5()
    md5.update(pwd.encode())
    return md5.hexdigest()

# print("md5",get_md5('213124124314'))

import requests
import json
class Login:
    def login(self,inData,getToken=True):
        url = f'{HOST}/account/sLogin'
        # inData = json.loads(inData)

        inData['password'] = get_md5(inData['password'])
        # payload = inData

        resp = requests.post(url,data=inData)
        # print(resp.text)


        if getToken:
            return resp.json()['data']['token']
        else:
            return resp.json()

if __name__ == '__main__':

    print(Login().login('''{"username":"sq0313","password":"111111"}'''))
